﻿@inherits BaseEditFormWithOption<BuildInputDTO, BuildInputDTO>

<Form @ref="_form" Model="@Data"
      LabelCol="new ColLayoutParam { Span = 6 }"
      WrapperCol="new ColLayoutParam { Span = 18 }">
    <FormItem Label="生成类型">
        <CheckboxGroup @bind-Value="@context.buildTypes">
            <Checkbox Label="0">实体层</Checkbox>
            <Checkbox Label="1">业务层</Checkbox>
            <Checkbox Label="2">接口层</Checkbox>
            <Checkbox Label="3">页面层</Checkbox>
        </CheckboxGroup>
    </FormItem>
    <FormItem Label="生成区域">
        <Input @bind-Value="@context.areaName" AutoComplete=false />
    </FormItem>
</Form>

@code {

    public EditForm()
    {
        Area = "Base_Manage";
    }

    protected override Task OnInitializedAsync()
    {
        Data = this.Options;
        return Task.CompletedTask;
    }

    protected override async Task SaveData(BuildInputDTO para)
    {
        using (var waitfor = WaitFor.GetWaitFor(this))
        {
            try
            {
                var result = await DataProvider.PostData<AjaxResult>($"/{Area}/BuildCode/Build", para.ToJson());
                if (!result.Success)
                {
                    throw new MsgException(result.Msg);
                }
            }
            catch (Exception ex)
            {
                await MessageService.Error(ex.Message);
            }
        }
    }
}